﻿@model ProductCreator

@section styles{
    @Styles.Render("~/Content/bootstrap-select.css")
}

@{
    string title = ViewBag.Title;
    string returnListUrl = ViewBag.ReturnListUrl;
    SelectList categoryDDL = ViewBag.CategoryDDL;
    SelectList brandDDL = ViewBag.BrandDDL;
    
    string controller = "product";

    ViewBag.Title = "Tạo mới " + title;
}

<section class="content-header">
    <h1>
        @title.ToUpper() <small>tạo mới</small>
    </h1>
    <ol class="breadcrumb">
        <li>
            <a href="@Url.Action("Index", "Admin")">
                <i class="fa fa-home"></i> Trang chủ
            </a>
        </li>
        <li>
            <a href="@Url.Action("Index")">Danh sách @title</a>
        </li>
        <li class="active">Tạo mới</li>
    </ol>
</section>

<section class="content">
    @using (Html.BeginForm("Create", "Product", FormMethod.Post, new { id = "frmCreateProduct" }))
    {
        @Html.AntiForgeryToken()
        @Html.Hidden("ReturnListUrl", returnListUrl)

        <div class="box box-primary">
            <div class="box-body">
                <div class="row">
                    <div class="col-md-4">
                        <div class="form-group">
                            <label class="control-label">
                                Danh mục
                            </label>
                            @Html.DropDownListFor(m => m.CategoryId, categoryDDL, "Chọn danh mục",
                            new
                            {
                                @class = "selectpicker no-margin",
                                data_width = "100%",
                                data_size = "auto",
                                data_live_search = "true"
                            })
                            @Html.ValidationMessageFor(m => m.CategoryId)
                        </div>
                        <div class="form-group">
                            <label class="control-label">
                                Thương hiệu
                            </label>
                            @Html.DropDownListFor(m => m.BrandId, brandDDL, "Chọn thương hiệu",
                            new
                            {
                                @class = "selectpicker no-margin",
                                data_width = "100%",
                                data_size = "auto",
                                data_live_search = "true"
                            })
                            @Html.ValidationMessageFor(m => m.BrandId)
                        </div>
                        <div class="form-group">
                            <label class="control-label">
                                Tên sản phẩm
                            </label>
                            @Html.TextAreaFor(m => m.Name, new { @class = "form-control" })
                            @Html.ValidationMessageFor(m => m.Name)
                        </div>
                        <div class="form-group">
                            <label class="control-label">
                                Mã nhận dạng
                            </label>
                            @Html.TextBoxFor(m => m.Code, new { @class = "form-control" })
                            @Html.ValidationMessageFor(m => m.Code)
                            <p class="help-block">Nếu để trống sẽ tự phát sinh mã sản phẩm.</p>
                        </div>
                        <div class="form-group">
                            <label class="control-label">
                                Giá thị trường
                            </label>
                            @Html.TextBoxFor(m => m.ListPrice, new { @class = "form-control" })
                            @Html.ValidationMessageFor(m => m.ListPrice)
                        </div>
                        <div class="form-group">
                            <label class="control-label">
                                Nguồn
                            </label>
                            @Html.TextAreaFor(m => m.SourceLink, new { @class = "form-control", rows = 4 })
                            @Html.ValidationMessageFor(m => m.SourceLink)
                        </div>
                    </div>
                    <div class="col-md-8">
                        <div class="form-group">
                            <label class="control-label">
                                Tóm tắt
                            </label>
                            @Html.TextAreaFor(m => m.Summary, new { @class = "form-control" })
                            @Html.ValidationMessageFor(m => m.Summary)
                        </div>
                        <div class="form-group">
                            <label class="control-label">
                                Mô tả
                            </label>
                            @Html.TextAreaFor(m => m.Description, new { @class = "form-control" })
                            @Html.ValidationMessageFor(m => m.Description)
                        </div>
                    </div>
                </div>
            </div>
            <div class="box-footer text-right">
                <a href="@Request.UrlReferrer" class="btn btn-default pull-left">
                    <i class="fa fa-chevron-left"></i> Quay lại
                </a>
                <button type="reset" class="btn btn-warning">
                    <i class="fa fa-repeat"></i> Mặc định
                </button>
                <button type="submit" class="btn btn-success">
                    <i class="fa fa-check"></i> Xác nhận
                </button>
            </div>
        </div>
    }
</section>

@section scripts{
    @Scripts.Render("~/Scripts/bootstrap-select.js")
    <script>
        $('.selectpicker').selectpicker();

        ActiveMenu('@controller');

        $(function () {
            $('#frmCreateProduct').data("validator").settings.ignore = "";
        });
    </script>
    @Scripts.Render("~/Scripts/ckeditor/ckeditor.js")
    <script>
        CKEDITOR.replace('Summary');
        CKEDITOR.replace('Description');
    </script>
}